#include "SceneManager.h"
#include "SceneGenerator.h"
#include "ViewerCameraSceneNode.h"
#include "LightSceneNode.h"
#include "../include/PowerLibraryEngine.h"

#include "Animators/MoveAnimator.h"
#include "Animators/RotateAnimator.h"
#include "Animators/ScalatorAnimator.h"

CSceneManager::CSceneManager(ISceneNodeReceiveParams):ISceneManager(ISceneNodeBasicParams)
{
    SetName("SceneManager");

	CSceneGenerator *sgentemp = new CSceneGenerator();
	sgen = sgentemp;

	dem = new CDrawableFaceManager();

	idbgvars = new CDebugVars();
	idbgvars->SetParent(this);
	idbgvars->SetName("DebugVars");

	pLogRelease << "CSceneManager created..." << endl;
}

CSceneManager::~CSceneManager()
{
	DEALLOCATE(sgen);
	DEALLOCATE(dem);
}

u32 CSceneManager::RenderAll(u32 Time)
{
	matrix3dvpos m(MCF_IDENTITY);
	RegistrationDataStrc rd;
	rd.dem = dem;
	rd.ParentAbsoluteMatrix = &m;
	rd.Time = Time;
	return RegisterNode(&rd);
}

void CSceneManager::Render(IDrawableFaceManager *dfm)
{
}

IDrawableFaceManager *CSceneManager::GetDrawableFaceManager()
{
	return dem;
}

void CSceneManager::SetActive3DCamera(I3DCameraSceneNode *newac)
{
	Active3DCamera = newac;
}

void CSceneManager::SetActive2DCamera(I2DCameraSceneNode *newac)
{
	Active2DCamera = newac;
}

void CSceneManager::UpdateNode()
{

}

void CSceneManager::OnRender()
{

}

void CSceneManager::AddMoveAnimator(ISceneNode *Node,vector3dvpos PosIni,vector3dvpos PosFin,u32 Time)
{
	Node->AddAnimator(new CMoveAnimator(PosIni,PosFin,Time));
}

void CSceneManager::AddRotationAnimator(ISceneNode *Node,vector3dvpos RotIni,vector3dvpos RotFin,u32 Time)
{
	Node->AddAnimator(new CRotateAnimator(RotIni,RotFin,Time));
}

void CSceneManager::AddScalatorAnimator(ISceneNode *Node,vector3dvpos ScalIni,vector3dvpos ScalFin,u32 Time)
{
	Node->AddAnimator(new CScalatorAnimator(ScalIni,ScalFin,Time));
}
